package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.behavior.pojos.ApCollection;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/v1")
@Api(value = "黑马头条APP行为处理API",tags = "黑马头条APP行为处理API")
public class BehaviorController {

    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;
    @Autowired
    ApReadBehaviorService apReadBehaviorService;
    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;
    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;
    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;

    @PostMapping("/likes_behavior")
    @ApiOperation("保存或取消点赞行为")
    public ResponseResult likesBehavior(@RequestBody @Validated LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }

    @PostMapping("/read_behavior")
    @ApiOperation("保存阅读行为")
    public ResponseResult readBehavior(@RequestBody @Validated ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }

    @PostMapping("/un_likes_behavior")
    @ApiOperation("保存或取消不喜欢行为")
    public ResponseResult unLikesBehavior(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @PostMapping("/collection_behavior")
    @ApiOperation("保存或取消收藏行为")
    public ResponseResult collectionBehavior(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }

    @PostMapping("/article/load_article_behavior")
    @ApiOperation("查询文章行为相关信息")
    public ResponseResult queryBehavior(@RequestBody @Validated ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }
}

